package com.chzu.controller;

import com.chzu.pojo.SemesterScore;
import com.chzu.pojo.vo.ScoreChartDateVo;
import com.chzu.result.JsonResult;
import com.chzu.result.QueryInfo;
import com.chzu.service.SemesterScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;
import java.util.List;

/**
 * @Author lz
 * @Version 1.0
 * @Company 滁州大健康与养老产业研究院
 * @ClassName SemesterScoreController
 * @Description 学期绩点分数
 * @Date 2022/02/10 21:12
 */
@RestController
@RequestMapping("/semesterScore")
@Api(tags = "学期绩点分数接口")
public class SemesterScoreController {

    @Resource
    private SemesterScoreService semesterScoreService;

    @ApiOperation("查询用户全部学期的绩点")
    @GetMapping("/")
    public JsonResult<List<SemesterScore>> getSemesterScore() {
        List<SemesterScore> data = semesterScoreService.getSemesterScore();
        return JsonResult.ok(data);
    }

    @ApiOperation("分页查询各个学期所有学生的绩点及学习积分")
    @PostMapping("/findPage/{semester}")
    public JsonResult<Object> getAllSemesterScore(@RequestBody QueryInfo queryInfo,@PathVariable("semester") String semester) {
        System.out.println(queryInfo.getQueryString());
        return semesterScoreService.getAllSemesterScore(queryInfo, semester);
    }

    @ApiOperation("获得各个绩点分段的人数")
    @GetMapping("/getNum")
    public JsonResult<List<ScoreChartDateVo>> getStudentNumByAverageScore() {
        List<ScoreChartDateVo> data = semesterScoreService.getStudentNumByAverageScore();
        return JsonResult.ok(data);
    }

    @ApiOperation("获取所有学期信息")
    @GetMapping("/getAllSemester")
    public JsonResult<Object> getAllSemester() {
        List<SemesterScore> data = semesterScoreService.getAllSemester();
        return JsonResult.ok(data);
    }
}
